<include file='Common:header' />

<!-- /section:basics/navbar.layout -->
<div class="main-container" id="main-container">

	<!-- #section:basics/sidebar -->

	<include file='Common:left' />


	<!-- /section:basics/sidebar -->
	<div class="main-content">
		<div class="main-content-inner">
			<div class="page-content">



				<!--主题-->
				<div class="page-header">
					<h1>
						您当前操作
						<small>
							<i class="ace-icon fa fa-angle-double-right"></i>
							站点设置
						</small>
					</h1>
				</div>

				<script>
					$(function(){
						$('textarea.limited').maxlength({
							'feedback' : '.charsLeft',
						});
						$('textarea.limited2').maxlength({
							'feedback' : '.charsLeft2',
						});
						$('textarea.limitedone').maxlength({
							'feedback' : '.charsLeftone',
						});
						$('textarea.limitedone2').maxlength({
							'feedback' : '.charsLeftone2',
						});
						$('#sys').ajaxForm({
							beforeSubmit: checkForm, // 此方法主要是提交前执行的方法，根据需要设置
							success: complete, // 这是提交后的方法
							dataType: 'json'
						});

						function checkForm(){
							if( '' == $.trim($('#site_name').val())){
								$('#resone').attr("class", "middle highmsg");//ID为resone 重新class赋值
								$('#resone').html('网站名称不能为空').show();//id为resone 赋值html值
								$('#site_name').focus();
								return false;
							}

							if( '' == $.trim($('#site_host').val())){
								$('#restwo').attr("class", "middle highmsg");//ID为resone 重新class赋值
								$('#resone').html('').show();//id为resone 赋值html值
								$('#restwo').html('网址不能为空').show();//id为resone 赋值html值
								$('#site_host').focus();
								return false;
							}

						}
						function complete(data){
							if(data.status==1){
								layer.alert(data.info, {icon: 6}, function(index){
									layer.close(index);
									window.location.href="{:U('Sys/sys')}";
								});
							}else{
								layer.alert(data.info, {icon: 5}, function(index){
								layer.close(index);
								//window.location.href="{:U('Sys/sys')}";
								});
								return false;
							}
						}
					});
				</script>
				<div class="row">
					
					<div class="tabbable">
	<ul class="nav nav-tabs" id="myTab">
		<li class="active">
			<a data-toggle="tab" href="#basic">
				基本设置
			</a>
		</li>

		<li>
			<a data-toggle="tab" href="#contact">
				联系方式
			</a>
		</li>

		<li class="dropdown">
			<a data-toggle="tab" href="#seo">
				SEO设置
			</a>
		</li>
	</ul>
<form class="form-horizontal" name="sys" id="sys" method="post" action="{:U('runsys')}">
<fieldset>
	<div class="tab-content">
		<div id="basic" class="tab-pane fade in active">
				<div class="form-group">
					<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 站点名称 </label>
					<div class="col-sm-9">
						<input type="text" name="options[site_name]" id="site_name" value="{$sys.site_name}" class="col-xs-10 col-sm-5" />
								<span class="help-inline col-xs-12 col-sm-7">
									<span class="middle" id="resone">*</span>
								</span>
					</div>
				</div>
				<div class="space-4"></div>

				<div class="form-group">
					<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 站点网址 </label>
					<div class="col-sm-9">
						<input type="text" name="options[site_host]" id="site_host" value="{$sys.site_host}"  class="col-xs-10 col-sm-5" />
								<span class="help-inline col-xs-12 col-sm-7">
									<span class="middle" id="restwo">*</span>
								</span>
					</div>
				</div>
				<div class="space-4"></div>

				<div class="form-group">
					<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 站点主题 </label>
					<div class="col-sm-9">
						<select name="options[site_tpl]" id="site_tpl" class="col-xs-10 col-sm-5">
							<foreach name="templates" item="vo">
							<option value="{$vo}" <if condition="$sys.site_tpl eq $vo">selected="selected"</if>>{$vo}</option>
							</foreach>
						</select>
						<span class="help-inline col-xs-12 col-sm-7">
							<span class="middle" id="restwo">*</span>
						</span>
					</div>
				</div>
				<div class="space-4"></div>
				
				<div class="form-group" id="pic_list">
					<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 网站LOGO </label>
					<div class="col-sm-9">
						<input type="hidden" name="checkpic" id="checkpic" value="{$sys.site_logo}" />
						<input type="hidden" name="oldcheckpic" id="oldcheckpic" value="{$sys.site_logo}" />
						<input type="hidden" name="oldcheckpicname" id="oldcheckpic" value="{$sys.site_logo}" />
						<a href="javascript:;" class="file" title="点击选择所要上传的图片">
							<input type="file" name="file0" id="file0" multiple="multiple"/>
							选择上传文件
						</a>
						&nbsp;&nbsp;<a href="javascript:;" onclick="return backpic('<if condition="$sys.site_logo eq ''">__PUBLIC__/img/no_img.jpg<else/>{$sys.site_logo}</if>');" title="还原修改前的图片" class="file">
						撤销上传
						</a>
						<div><img src="<if condition="$sys.site_logo neq ''">{$sys.site_logo}<else/>__PUBLIC__/img/no_img.jpg</if>" height="70" id="img0" ></div>
					</div>
				</div>
				<div class="space-4"></div>
				
				<div class="form-group">
					<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 备案信息 </label>
					<div class="col-sm-9">
						<input type="text" name="options[site_icp]" id="site_icp" value="{$sys.site_icp}"  class="col-xs-10 col-sm-5" />
								<span class="help-inline col-xs-12 col-sm-7">
									<span class="middle" id="restwo"></span>
								</span>
					</div>
				</div>
				<div class="space-4"></div>

				<div class="form-group">
					<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 统计代码 </label>
					<div class="col-sm-9">
						<textarea  name="options[site_tongji]" cols="20" rows="2" class="col-xs-10 col-sm-7 limited"   id="form-field-9"  maxlength="100">{$sys.site_tongji}</textarea>
						<input type="hidden" name="maxlengthone" value="100" />
								<span class="help-inline col-xs-5 col-sm-5">
									还可以输入 <span class="middle charsLeft"></span> 个字符
								</span>
					</div>
				</div>
				<div class="space-4"></div>	

				<div class="form-group">
					<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 版权信息 </label>
					<div class="col-sm-9">
						<textarea  name="options[site_copyright]" cols="20" rows="3" class="col-xs-10 col-sm-7 limitedone"   id="form-field-10"  maxlength="150">{$sys.site_copyright}</textarea>
						<input type="hidden" name="maxlengthone" value="150" />
								<span class="help-inline col-xs-5 col-sm-5">
									还可以输入 <span class="middle charsLeftone"></span> 个字符
								</span>
					</div>
				</div>
				<div class="space-4"></div>								
		</div>

		<div id="contact" class="tab-pane fade">
				<div class="form-group">
					<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 公司名称 </label>
					<div class="col-sm-9">
						<input type="text" name="options[site_co_name]" id="site_co_name" value="{$sys.site_co_name}" class="col-xs-10 col-sm-5" />
								<span class="help-inline col-xs-12 col-sm-7">
									<span class="middle" id="resone"></span>
								</span>
					</div>
				</div>
				<div class="space-4"></div>

				<div class="form-group">
					<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 公司地址 </label>
					<div class="col-sm-9">
						<input type="text" name="options[site_address]" id="site_address" value="{$sys.site_address}"  class="col-xs-10 col-sm-5" />
								<span class="help-inline col-xs-12 col-sm-7">
									<span class="middle" id="restwo"></span>
								</span>
					</div>
				</div>
				<div class="space-4"></div>
				
				<div class="form-group">
					<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 联系电话 </label>
					<div class="col-sm-9">
						<input type="text" name="options[site_tel]" id="site_tel" value="{$sys.site_tel}"  class="col-xs-10 col-sm-5" />
								<span class="help-inline col-xs-12 col-sm-7">
									<span class="middle" id="restwo"></span>
								</span>
					</div>
				</div>
				<div class="space-4"></div>

				<div class="form-group">
					<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 站长邮箱 </label>
					<div class="col-sm-9">
						<input type="text" name="options[site_admin_email]" id="site_admin_email" value="{$sys.site_admin_email}"  class="col-xs-10 col-sm-5" />
								<span class="help-inline col-xs-12 col-sm-7">
									<span class="middle" id="restwo"></span>
								</span>
					</div>
				</div>
				<div class="space-4"></div>

				<div class="form-group">
					<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 站长QQ </label>
					<div class="col-sm-9">
						<input type="text" name="options[site_qq]" id="site_qq" value="{$sys.site_qq}"  class="col-xs-10 col-sm-5" />
								<span class="help-inline col-xs-12 col-sm-7">
									<span class="middle" id="restwo"></span>
								</span>
					</div>
				</div>
				<div class="space-4"></div>							
		</div>

		<div id="seo" class="tab-pane fade">
				<div class="form-group">
					<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 首页SEO标题 </label>
					<div class="col-sm-9">
						<input type="text" name="options[site_seo_title]" id="site_seo_title" value="{$sys.site_seo_title}"  class="col-xs-10 col-sm-5" />
								<span class="help-inline col-xs-12 col-sm-7">
									<span class="middle" id="resthr"></span>
								</span>
					</div>
				</div>
				<div class="space-4"></div>

				<div class="form-group">
					<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 首页SEO关键字 </label>
					<div class="col-sm-9">
						<textarea  name="options[site_seo_keywords]" cols="20" class="col-xs-10 col-sm-7 limited2"  id="form-field-11"  maxlength="100">{$sys.site_seo_keywords}</textarea>
						<input type="hidden" name="maxlength" value="100" />
								<span class="help-inline col-xs-5 col-sm-5">
									还可以输入 <span class="middle charsLeft2"></span> 个字符,以英文 , 号隔开
								</span>
					</div>
				</div>
				<div class="space-4"></div>

				<div class="form-group">
					<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 首页SEO描述 </label>
					<div class="col-sm-9">
						<textarea  name="options[site_seo_description]" cols="20" rows="4" class="col-xs-10 col-sm-7 limitedone2"   id="form-field-12"  maxlength="200">{$sys.site_seo_description}</textarea>
						<input type="hidden" name="maxlengthone" value="200" />
								<span class="help-inline col-xs-5 col-sm-5">
									还可以输入 <span class="middle charsLeftone2"></span> 个字符
								</span>
					</div>
				</div>
				<div class="space-4"></div>
		</div>
	</div>
				<div class="clearfix form-actions">
					<div class="col-sm-offset-3 col-sm-9">
						<button class="btn btn-info" type="submit">
							<i class="ace-icon fa fa-check bigger-110"></i>
							保存
						</button>

						&nbsp; &nbsp; &nbsp;
						<button class="btn" type="reset">
							<i class="ace-icon fa fa-undo bigger-110"></i>
							重置
						</button>
					</div>
				</div>
	</fieldset>
</form>
</div>
				</div>
				<!-- <div class="hr hr-24"></div> -->

				<include file='Common:header_nav' />

			</div><!-- /.page-content -->
		</div>
	</div><!-- /.main-content -->


	<include file='Common:footer' />
	<script>
		//还原之前图片
		function backpic(picurl){
			$("#img0").attr("src",picurl);//还原修改前的图片
			$("input[name='file0']").val("");//清空文本框的值
			$("input[name='oldcheckpic']").val(picurl);//清空文本框的值
		}
		//图片变更
		$("#file0").change(function(){
			var objUrl = getObjectURL(this.files[0]) ;
			console.log("objUrl = "+objUrl) ;
			if (objUrl) {
				$("#img0").attr("src", objUrl) ;
			}
		}) ;

		//建立一個可存取到該file的url
		function getObjectURL(file) {
			var url = null ;
			if (window.createObjectURL!=undefined) { // basic
				$("#oldcheckpic").val("nopic");
				url = window.createObjectURL(file) ;
			} else if (window.URL!=undefined) { // mozilla(firefox)
				$("#oldcheckpic").val("nopic");
				url = window.URL.createObjectURL(file) ;
			} else if (window.webkitURL!=undefined) { // webkit or chrome
				$("#oldcheckpic").val("nopic");
				url = window.webkitURL.createObjectURL(file) ;
			}
			return url ;
		}
	</script>
	</body>
	</html>
